package com.xiliu.rocketmq.component;

import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @author xiliu
 * @description
 * @date 2022/3/3
 */
@Component
@RocketMQMessageListener(consumerGroup = "xiliu_consumer_group", topic = "broker-a",
        selectorExpression = "xiliu_tag", selectorType = SelectorType.TAG,
        messageModel = MessageModel.CLUSTERING, consumeMode = ConsumeMode.CONCURRENTLY)
public class MessageConsumer implements RocketMQListener<String>{

    @Override
    public void onMessage(String s) {
        try {
            System.out.println("接收到rocketmq消息:" + s);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
